package com.eascs.web.o2o.report.dao;

import java.util.List;

import javax.inject.Inject;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.eascs.app.dao.JdbcSession;

@Repository
public class WorkflowReportDao {
	@Inject
	JdbcSession jdbcSessionForWorkflow;
	

	

	

	public <T> List<T> findEntitys(String sql, Class<T> requiredType, Object... params) {

		return jdbcSessionForWorkflow.findEntitys(sql, requiredType, params);
	}

	/**
	 * s 保存该表数据
	 */
	@Transactional(transactionManager = "transactionManagerDbForWorkflow")
	public void saveEntity(Object entity) {
		jdbcSessionForWorkflow.insert(entity);
	}

	/**
	 * 删除数据
	 */
	public void deleteEntity(String delSql) {
		jdbcSessionForWorkflow.execute(delSql);
	}

	/**
	 * @param sql
	 *            保存
	 */
    @Transactional(transactionManager = "transactionManagerDbForWorkflow")
	public int excuteSql(String sql, Object... params) {

    	return jdbcSessionForWorkflow.execute(sql, params);

	}
    
    /**
	 * 执行存储过程
	 */
	public void excute(String proSql){
		jdbcSessionForWorkflow.execute(proSql);
	}
    

    public Integer countMysql(String sql,Object... params) {
		String countSql = "select count(1) from (" + sql + ") t";
		return this.jdbcSessionForWorkflow.findInteger(countSql, params);

	}
}
